package service;

import Dao.UserDao;
import Dao.UserDaoImpl;
import entity.User;
import service.UserService;
import util.DatabaseUtil;

import java.sql.Connection;
import java.sql.SQLException;

public class UserServiceImpl implements UserService {
    private Connection conn = null;
    UserDao userDao = null;
    public UserServiceImpl() {
        conn = DatabaseUtil.getConnection();
        userDao = new UserDaoImpl(conn);
    }
    @Override
    public User login(String username, String password) throws SQLException {
        return userDao.login(username,password);
    }

    @Override
    public int register(User user) throws SQLException {
        return userDao.register(user);
    }

    @Override
    public User phones(String phone) throws SQLException {
        return userDao.phones(phone);
    }

    @Override
    public User emails(String email) throws SQLException {
        return userDao.emails(email);
    }

    @Override
    public User usernames(String username) throws SQLException {
        return userDao.usernames(username);
    }

    @Override
    public User getMessage(String name){
        return userDao.getMessage(name);
    }

    @Override
    public int updateUser(User user) {
        return userDao.updateUser(user);
    }

    @Override
    public int updatePwd(User user) {
        return userDao.updatePwd(user);
    }

    @Override
    public int wogout(int id) {
        return userDao.wogout(id);
    }
}
